package com.zwy.booksystem.component;

import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Component
public class interceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        Object info = request.getSession().getAttribute("userInfo");
        if (info!=null){
            return true;
        }

        request.getRequestDispatcher("/index").forward(request,response);

        return true;
    }
}
